home *** CD-ROM | disk | FTP | other *** search
/ Champak 120 / Vol 120.iso / games / titans / beastboy.swf / scripts / DefineSprite_309 / frame_1 / DoAction.as
Text File  |  2010-11-09  |  1KB  |  74 lines

  1. range = 200;
  2. speed = r.runspeed;
  3. xmin = _X - range;
  4. xmax = _X + range;
  5. shotdelay = 10;
  6. runtime = 150;
  7. blast._visible = 0;
  8. x = _X;
  9. run = 0;
  10. onenterframe = function()
  11. {
  12.    if(run)
  13.    {
  14.       if(p._x > _X + speed)
  15.       {
  16.          xs = speed;
  17.       }
  18.       else if(p._x < _X - speed)
  19.       {
  20.          xs = - speed;
  21.       }
  22.       else
  23.       {
  24.          xs = 0;
  25.       }
  26.       _X = _X + xs;
  27.       if(_X > xmax)
  28.       {
  29.          _X = xmax;
  30.          xs = - xs;
  31.       }
  32.       else if(_X < xmin)
  33.       {
  34.          _X = xmin;
  35.          xs = - xs;
  36.       }
  37.       d--;
  38.       if(!d)
  39.       {
  40.          d = shotdelay;
  41.          blast._visible = 1;
  42.          blastdelay = 4;
  43.       }
  44.       if(blastdelay > 0)
  45.       {
  46.          blastdelay--;
  47.          cekhitp(z2);
  48.          if(!blastdelay)
  49.          {
  50.             blast._visible = 0;
  51.          }
  52.       }
  53.       rund--;
  54.       if(rund < 20)
  55.       {
  56.          _X = x + (_X - x) / 1.2;
  57.       }
  58.       if(rund < 0)
  59.       {
  60.          run = 0;
  61.          blast._visible = 0;
  62.       }
  63.    }
  64.    if(!run and z2.hittest(p.z))
  65.    {
  66.       run = 1;
  67.       rund = runtime;
  68.       blastdelay = 0;
  69.       d = shotdelay;
  70.    }
  71.    cekhitp(z);
  72. };
  73. stop();
  74.